package control;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.National;
import model.User;
public class DelUser extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public DelUser() {
        super();
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		String n = request.getParameter("uid");
		String del = request.getParameter("delete");
		User u = new User();
		if (del.equals("yes")) {
			u.del(Integer.parseInt(n));
			request.setAttribute("m", "del-uok");
			request.setAttribute("r","vu");
			RequestDispatcher transferexist = getServletContext().getRequestDispatcher("/a/message.jsp");
			transferexist.forward(request, response);
		} else {
			RequestDispatcher transfer = getServletContext().getRequestDispatcher("/a/user.jsp");
			transfer.forward(request, response);
		}
	}

}
